From 199dec86baf8048feb490e5dcce00022a9f37fe5 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 2 Jul 2017 12:08:49 +0300 Subject: [PATCH] Refactor: virtual manifest does not need layout --- src/cargo/util/toml.rs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/cargo/util/toml.rs b/src/cargo/util/toml.rs index 3803d59e6..0f7303f90 100644 --- a/src/cargo/util/toml.rs +++ b/src/cargo/util/toml.rs @@ -122,20 +122,20 @@ pub fn read_manifest(path: &Path, source_id: &SourceId, config: &Config) } fn do_read_manifest(contents: &str, - path: &Path, + manifest_file: &Path, source_id: &SourceId, config: &Config) -> CargoResult<(EitherManifest, Vec)> { + let root = manifest_file.parent().unwrap(); + let layout = Layout::from_project_path(root); - let layout = Layout::from_project_path(path.parent().unwrap()); - - let root = { - let pretty_filename = util::without_prefix(path, config.cwd()).unwrap_or(path); + let toml = { + let pretty_filename = util::without_prefix(manifest_file, config.cwd()).unwrap_or(manifest_file); parse(contents, pretty_filename, config)? }; let mut unused = BTreeSet::new(); - let manifest: TomlManifest = serde_ignored::deserialize(root, |path| { + let manifest: TomlManifest = serde_ignored::deserialize(toml, |path| { let mut key = String::new(); stringify(&mut key, &path); unused.insert(key); @@ -160,7 +160,7 @@ fn do_read_manifest(contents: &str, Err(e) => { match TomlManifest::to_virtual_manifest(&manifest, source_id, - &layout, + &root, config) { Ok((m, paths)) => Ok((EitherManifest::Virtual(m), paths)), Err(..) => Err(e), @@ -509,7 +509,7 @@ struct Context<'a, 'b> { config: &'b Config, warnings: &'a mut Vec, platform: Option, - layout: &'a Layout, + root: &'a Path, } // These functions produce the equivalent of specific manifest entries. One @@ -804,7 +804,7 @@ impl TomlManifest { config: config, warnings: &mut warnings, platform: None, - layout: layout, + root: &layout.root, }; fn process_dependencies( @@ -924,7 +924,7 @@ impl TomlManifest { fn to_virtual_manifest(me: &Rc, source_id: &SourceId, - layout: &Layout, + root: &Path, config: &Config) -> CargoResult<(VirtualManifest, Vec)> { if me.project.is_some() { @@ -960,7 +960,7 @@ impl TomlManifest { config: config, warnings: &mut warnings, platform: None, - layout: layout, + root: root })?; let profiles = build_profiles(&me.profile); let workspace_config = match me.workspace { @@ -1137,7 +1137,7 @@ impl TomlDependency { // always end up hashing to the same value no matter where it's // built from. if cx.source_id.is_path() { - let path = cx.layout.root.join(path); + let path = cx.root.join(path); let path = util::normalize_path(&path); SourceId::for_path(&path)? } else { -- 2.30.2